package study.javase.thread;

/**
 * 静态代理
 * 1.真实角色
 * 2.代理角色
 * 二者需要实现同一接口
 * @author LiShaowen
 * @date 2020/9/4 17:32
 */
public class StaticProxy {
    public static void main(String[] args) {
        new WeddingCompany(new You()).happyMarry();
    }
}


    interface Marry{
        void happyMarry();
    }

// You是真实
 class You implements Marry{
    @Override
    public void happyMarry() {
        System.out.println("You 终于结婚了");
    }
}
// 婚庆公司代理角色
 class WeddingCompany implements Marry{

    // 真实角色
    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }

    @Override
    public void happyMarry() {
        ready();
        this.target.happyMarry();
        after();
    }

    private void ready() {
        System.out.println("布置结婚现场");
    }
    private void after() {
        System.out.println("洞房花烛夜");
    }
}


